package com.dana1.nos.old;

import java.util.List;
import java.util.Map;

public interface ObjectService
{
	// object handling operations
	public <T extends ServiceObject> T newInstance(Class<T> iObjClass);
	public <T extends ServiceObject> ObjectKey<T> objectKey(T obj);
	
	// search operations
	public <T extends ServiceObject> List<ObjectKey<T>> query(T obj);

	// passthru operation. The multiple sql statements are so that a true list of affected object keys can be returned by the underlying driver
	public List<ObjectKey<?>> execute(Map<String,Object> parameters, String ... sql);

	// Object operations
	public <T extends ServiceObject> ObjectKey<T> insert(T obj);
	public <T extends ServiceObject> T retrieve(ObjectKey<T> key);
	public <T extends ServiceObject> void update(T obj);
	public <T extends ServiceObject> void delete(ObjectKey<T> key);
	
	public List<ObjectKey<?>> insert(List<ServiceObject> objs);
	public List<ServiceObject> retrieve(List<ObjectKey<?>> keys);
	public void update(List<ServiceObject> objs);
	public void delete(List<ObjectKey<?>> keys);

	// basic m-m relation operators
	public List<ObjectKey<?>> retrieveMM(ObjectKey<? extends ServiceObject> ownerKey,String relationName);
	public int countMM(ObjectKey<? extends ServiceObject> ownerKey,String relationName);
	public boolean addMM(ObjectKey<? extends ServiceObject> ownerKey, String relationName, ObjectKey<? extends ServiceObject> childKey);
	public boolean removeMM(ObjectKey<? extends ServiceObject> ownerKey, String relationName, ObjectKey<? extends ServiceObject> childKey);

	// basic 1-m relation operators
	public <T extends ServiceObject> List<ObjectKey<T>> retrieve1M(ObjectKey<? extends ServiceObject> childKey, Class<T> parentObjectClass, String relationName);
	public int count1M(ObjectKey<? extends ServiceObject> childKey, Class<? extends ServiceObject> parentObjectClass, String relationName);
	public boolean add1M(ObjectKey<? extends ServiceObject> childKey, String relationName, ObjectKey<? extends ServiceObject> parentKey);
	public boolean remove1M(ObjectKey<? extends ServiceObject> childKey, String relationName, ObjectKey<? extends ServiceObject> parentKey);

	// basic 1-1 relation operators
	public boolean set11(ObjectKey<? extends ServiceObject> parentKey, String relationName, ObjectKey<? extends ServiceObject> childKey);
	
	
}
